package zhuzx.solution.ir;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.zhuzx.util.GeneralUtil;

public class IrSpecialDataProcessor {
	
	public static void main(String[] args) {
		solveOrgBracketProblem();
	}
	
	/**
	 * 插入南部营销的新组织，但根据这个新组织关联到原公司。
	 * 把qywx_org_name作为orgName插入，而其orgNo3、orgNo4两个字段值都使用address表中用户原来的部门编码。
	 */
	static void insertAllSouthernMarketingOrg() {
		String sql = "select distinct(t.qywx_org_name) as ORG, "
				+ "t.ORG_NUMBER2, t.ORG_NUMBER3, t.ORG_NUMBER4\n"
				+ "from OA.IR_ADDRESS_BOOK t\n"
				+ "where t.qywx_org_name like '%南部营销%'";
		List<Map<String,String>> list = IrDataHelper.query(
				"query SouthernMarketingOrg", sql, null);
		System.out.println("查询到" + list.size() + "个【南部营销】");
		List<Boolean> results = new ArrayList<>();
		for (Map<String,String> map : list) {
			results.add(IrOrgProcessor.insertOrg(map.get("ORG"),
					map.get("ORG_NUMBER2"), map.get("ORG_NUMBER3"), map.get("ORG_NUMBER4")));
		}
		System.out.println("运行结果：\n" + GeneralUtil.getCombinedString(results, "\n"));
	}
	
	/**
	 * 解决同时存在中英文括号导致的打卡数据中的组织异常问题
	 */
	static void solveOrgBracketProblem() {
		String clause = "qywx_org_name like '%(%' and qywx_org_name like '%（%'";
		IrCompanyBulkProcessor.solveOrgProblematicUser(clause);
	}
	
}